package com.mdtx.base.exception;

import com.mdtx.base.SystemErrorCode;
import com.mdtx.business.BusinessErrorCode;

/**
 * 异常
 *
 * @author zhgz
 * @create 2017-08-23 22:48
 **/
public class BaseException extends RuntimeException{

    /**
     * 异常代码
     */
    private Integer code;


    protected static  enum exceptionType{

        CONTROLLER("Controller"),
        SERVICE("Service"),
        MANAGER("Manager"),
        DAO("Dao");

        private final String type;

        private exceptionType(final String type){
            this.type=type;
        }

        public String toString(){
            return type;
    }

    }

    public BaseException(BusinessErrorCode se) {
        super(se.getErrorInfo());
        this.code = se.getCode();
    }


    public BaseException(BusinessErrorCode se,Throwable cause) {
        super(se.getErrorInfo(), cause);
        this.code = se.getCode();
    }

    public BaseException(SystemErrorCode se) {
        super(se.getErrorInfo());
        this.code = se.getCode();
    }


    public BaseException(SystemErrorCode se,Throwable cause) {
        super(se.getErrorInfo(), cause);
        this.code = se.getCode();
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getExceptionType(){
        return null;
    }
}
